import Vue from 'vue'
import Router from 'vue-router'
import login from '@/views/login'
import Layout from '@/views/layout/layout'

Vue.use(Router)

/**
 *  hidden  //当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面
 * alwaysShow //展示一级页面
 */
export const constantRouterMap = [   // 代表那些不需要动态判断权限的路由，如登录页、404、等通用页面。
    {
        path: '/redirect',
        component: Layout,
        hidden: true,
        children: [
            {
                path: '/redirect/:path*',
                component: () => import('@/views/redirect/index')
            }
        ]
    },
    {
        path: '/',
        redirect: '/login',
        hidden: true,
    },
    {
        path: '/login',
        hidden: true,
        component: login,
    },
    {
        path: '/forgetPwd',
        hidden: true,
        component: () => import('@/views/codeForm_Pwd/index')
    },
    {
        path: '',
        redirect: 'home',
        component: Layout,
        alwaysShow: true,
        children: [
            {
                path: 'home',
                component: () => import('@/views/home/index'),
                meta: {
                    title: '首页'
                }
            }
        ]
    },
    {
        path: '/404',
        component: () => import('@/views/errorPage/404'),
        hidden: true
    },
    {
        path: '/401',
        hidden: true,
        component: () => import('@/views/errorPage/401')
    },
]


export default new Router({
    base: process.env.BASE_URL,
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRouterMap
})
